#include <iostream>
#include <fstream>
#include <sstream>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
using namespace std;

int main(int argn,char **argv){
	assert(argv[1][0]!='\0');
	ifstream in(argv[1]);

	string outname("before_cat/");
	string arg(argv[1]);
	outname += arg.substr(arg.find('/')+1);

	ofstream fout;
	fout.open(outname.c_str());

	int begin = arg.find('/')+1;
	int end = arg.find('.');
	fout << "\'" << arg.substr(begin,end-begin) << "\':{" << endl;
	fout << "'detail':{" << endl;

	string line;
	int num = 0;
	while(in >> line){
		int i = 0;
		int len = line.size();
		vector<string> vs;
		while(i<len){
			string tmp;
			while(line[i]!=',' && line[i]!='\0'){
				tmp += line[i];
				++i;
			}
			vs.push_back(tmp);
			++i;
		}

		if(num!=0) fout << ",";
		++num;

//'上海市嘉定区血站': {'name':'上海市嘉定区血站', 'll':{'tp':'1', 'lat': '31.3856805986', 'lng':'121.256747246'}, 'adr':'金沙路255号', 'tel':'021-87654321', 'url':'www.xxx.com', 'desc':'9:00-17:00开'}
//
		fout << "\'" << vs[0] << "\':{"
			<< "\'name\':\'" << vs[0] << "\'" << ","
			<< "\'ll\':{\'tp\':\'" << vs[10] << "\',\'lat\':\'" << vs[8] 
			<< "\',\'lng\':\'" << vs[9] << "\'}";
		if(!vs[4].empty()){
			fout << ",\'adr\':\'" << vs[4] << "\'";
		}
		if(!vs[5].empty() || !vs[6].empty()){
			if(!vs[5].empty() && !vs[6].empty()){
				fout << ",\'tel\':\'" << vs[6] << "/"<< vs[5] << "\'";
			}else{
				fout << ",\'tel\':\'" << vs[6] << vs[5] << "\'";
			}
		}
		if(!vs[7].empty()){
			fout << ",\'url\':\'" << vs[7] << "\'";
		}
		fout << "}" << endl;
	}

	fout << "}" << endl;
	fout << "}" << endl;
	fout.close();
	return 0;
}

